package com.itlong.cloud.commons.resource;

import com.itlong.cloud.POJO.DTO.common.LimitedDeviceDto;
import com.itlong.cloud.POJO.DTO.property.CloudIntercomChangeLogGetDTO;
import com.itlong.cloud.POJO.PO.DeviceOnlineStatusAlterLogPO;
import com.itlong.cloud.POJO.PO.DeviceRunLogPO;
import com.itlong.cloud.POJO.VO.common.LimitedDeviceVO;
import com.itlong.cloud.commons.service.ICloudDeviceBaseService;
import com.itlong.cloud.equip.commons.ICloudDeviceBaseServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 * <desc>
 *      设备业务暴露接口实现类
 * </desc>
 *
 * @create 2018/03/28
 */


@RestController
public class CloudDeviceBaseServiceResource implements ICloudDeviceBaseServiceClient {

    @Autowired
    private ICloudDeviceBaseService iCloudDeviceBaseService;
    /**
     * <desc>
     * 保存受限设备和缓存设备最新更新时间
     * </desc>
     *
     * @param getDTO
     * @return
     * @author caoshuai
     * @createDate 2020/11/20 18:07
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/saveLimitedDevice",method = {RequestMethod.POST})
    public LimitedDeviceVO saveLimitedDevice(@RequestBody LimitedDeviceDto getDTO) throws UnsupportedEncodingException {
        return iCloudDeviceBaseService.saveLimitedDevice(getDTO);
    }

    /**
     * <desc>
     *      保存设备在线状态变更
     * </desc>
     *
     * @param deviceOnlineStatusAlterLogPO
     * @author caoshuai
     * @createDate 2020/11/24 15:29
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/saveDeviceOnlineStatusAlterLog",method = {RequestMethod.POST})
    public void saveDeviceOnlineStatusAlterLog(@RequestBody DeviceOnlineStatusAlterLogPO deviceOnlineStatusAlterLogPO) {
        iCloudDeviceBaseService.saveDeviceOnlineStatusAlterLog(deviceOnlineStatusAlterLogPO);

    }

    /**
     * <desc>
     * 保存设备日志信息
     * </desc>
     *
     * @param deviceRunLogPO@return
     * @author caoshuai
     * @createDate 2020/12/3 14:17
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/saveDeviceRunLog",method = {RequestMethod.POST})
    public Integer saveDeviceRunLog(@RequestBody DeviceRunLogPO deviceRunLogPO) throws Exception {

        return iCloudDeviceBaseService.saveDeviceRunLog(deviceRunLogPO);
    }

    /**
     * <desc>
     *  修改设备运行日志上传状态
     * </desc>
     *
     * @param deviceRunLogPO@return
     * @author caoshuai
     * @createDate 2020/12/3 14:17
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/updateDeviceRunLog",method = {RequestMethod.POST})
    public Integer updateDeviceRunLog(@RequestBody DeviceRunLogPO deviceRunLogPO) {
        return iCloudDeviceBaseService.updateDeviceRunLog(deviceRunLogPO);
    }

    /**
     * <desc>
     * 获取受限getDTO 获取受限设备总数
     * </desc>
     *
     * @param getDTO
     * @return
     * @author caoshuai
     * @createDate 2020/12/3 14:17
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/getLimitDeviceTotalByDTO",method = {RequestMethod.POST})
    public Integer getLimitDeviceTotalByDTO(@RequestBody CloudIntercomChangeLogGetDTO getDTO) {
        return iCloudDeviceBaseService.getLimitDeviceTotalByDTO(getDTO);
    }

    /**
     * <desc>
     * 获取平板受限设备总数
     * </desc>
     *
     * @param deviceUnique
     * @return
     * @author caoshuai
     * @createDate 2020/12/3 14:17
     */
    @Override
    @RequestMapping(path = "/smartCommunity/interface/base/getLimitDevicePadTotalBy",method = {RequestMethod.POST})
    public Integer getLimitDevicePadTotalBy(@RequestParam("deviceUnique") String deviceUnique) {
        return iCloudDeviceBaseService.getLimitDevicePadTotalBy(deviceUnique);
    }
}
